1f7eafc926c290433b806443c391a0fff5c92d3b,samples/iotfdeviceclient/src/com/ibm/iotf/sample/client/gateway/SampleRasPiGateway.java,SampleRasPiGateway,addDevice,#String#String#,167
Before Change
private void addDevice(String deviceType, String deviceId) throws IoTFCReSTException {
try {
System.out.println("<-- Adding device " + deviceId);
this.gwClient.api().getDevice(deviceType, deviceId);
} catch (IoTFCReSTException ex) {
if (ex.getHttpCode() == 404) {
gwClient.api().registerDeviceUnderGateway(deviceType, deviceId,
After Change
* Add a device under the given gateway using the Java Client Library.
* @throws IoTFCReSTException
*/
private void addDevice(String deviceType, String deviceId) throws IoTFCReSTException {
try {
System.out.println("<-- Checking if device " + deviceId +" with deviceType " +
deviceType +" exists in Watson IoT Platform");
boolean exist = this.gwClient.api().isDeviceExist(deviceType, deviceId);
if(!exist) {
System.out.println("<-- Creating device " + deviceId +" with deviceType " +
deviceType +" now..");
gwClient.api().registerDeviceUnderGateway(deviceType, deviceId,
this.gwClient.getGWDeviceType(),
this.gwClient.getGWDeviceId());